<div>
    <div class="content d-flex flex-column flex-column-fluid">

        <sub-header [title]="'PropertyEdit' | localize" [description]="property?.id+' | '+property?.name">
            <div action="back"><i class="icon-fanhui text-info" (click)="goBack()"></i></div>
            <div role="actions">
            </div>
        </sub-header>

        <div [class]="containerClass">
            <div class="card card-custom gutter-b">
                <div class="card-body">
                    <form #propertyInfooperationForm="ngForm" name="ProductCategoryForm" novalidate (ngSubmit)="save()"
                        autocomplete="off">
                        <tabset class="tab-container tabbable-line">
                            <tab class="pt-5" heading="{{l('BaseMsg')}}" customClass="kt-tabs__item">
                                <form style="width: 100%" novalidate="" #propertyInfooperationForm="ngForm"
                                    (ngSubmit)="save()">
                                    <div class="form-row">
                                        <div class="col-8">
                                            <div class="form-group">
                                                <label class="control-label">{{l('name')}}</label>
                                                <input class="form-control " id="name" name="name" required
                                                    [(ngModel)]="property.name" type="text">
                                            </div>
                                            <div class="form-group">
                                                <label class="control-label"
                                                    for="description">{{l('description')}}</label>
                                                <textarea class="form-control " id="description" name="description"
                                                    [(ngModel)]="property.description"></textarea>
                                            </div>
                                            <div class="form-group">
                                                <div class="checkbox-list form-group">
                                                    <label class="checkbox checkbox-success">
                                                        <input type="checkbox" name="isForSale"
                                                            [(ngModel)]="property.isForSale"> {{l("isForSale")}}
                                                        <span></span>
                                                    </label>
                                                    <label class="checkbox checkbox-success"
                                                        *ngIf="property?.isForSale">
                                                        <input type="checkbox" name="isDefaultDecideImage"
                                                            [(ngModel)]="property.isDefaultDecideImage">
                                                        {{l("isDefaultDecideImage")}}
                                                        <span></span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group col-4">
                                            <label class="control-label" for="icon">{{l('icon')}}</label>
                                            <app-fileupload [fileUrl]="property.iconUrl"
                                                (onUpLoadEvent)="onUpload($event)"
                                                (onBeforeSendEvent)="onBeforeSend($event)"></app-fileupload>
                                        </div>

                                    </div>
                                    <div class="hr-line-dashed"></div>
                                    <div class="form-group">
                                        <div class="col-md-12 text-right">
                                            <button class="btn btn-primary" (click)="goBack()">{{l('back')}}</button>
                                            <button class="btn btn-primary"
                                                [disabled]="!propertyInfooperationForm.form.valid" [buttonBusy]="saving"
                                                [busyText]="l('SavingWithThreeDot')"
                                                type="submit">{{l('Save')}}</button>
                                        </div>
                                    </div>
                                </form>
                            </tab>
                            <tab class="pt-5" heading="{{l('propertyValue')}}" customClass="kt-tabs__item"
                                (selectTab)="getPropertyValue($event)">
                                <div class="row align-items-center">
                                    <form class="horizontal-form" autocomplete="off" name="propertysForm">
                                        <div class="m-form m-form--label-align-right">
                                            <div class="row align-items-center m--margin-bottom-10">
                                                <div class="col-6">
                                                    <div class="form-group m-form__group align-items-center">
                                                        <div class="input-group">
                                                            <input [(ngModel)]="filterText" name="filterText"
                                                                (keyup.enter)="getPropertyValue()" autoFocus
                                                                class="form-control m-input" [placeholder]="l('name')"
                                                                type="text">
                                                            <span class="input-group-btn">
                                                                <button (click)="getPropertyValue()"
                                                                    class="btn btn-primary" type="submit">
                                                                    <i class="icon-sousuo-sousuo"></i>
                                                                </button>
                                                            </span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-6">
                                                    <div class="form-group text-right">
                                                        <button (click)="addPropertyValue()"
                                                            class="btn btn-primary icon-add" type="submit">
                                                            {{l('CreatePropertyValue')}}
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </form>

                                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                                        <p-table #dataTable (onLazyLoad)="getPropertyValue($event)"
                                            [value]="primengTableHelper.records"
                                            [rows]="primengTableHelper.defaultRecordsCountPerPage" [paginator]="false"
                                            [lazy]="true" [resizableColumns]="primengTableHelper.resizableColumns"
                                            [responsive]="primengTableHelper.isResponsive">
                                            <ng-template pTemplate="header">
                                                <tr>
                                                    <th>{{l('Actions')}}</th>
                                                    <th style="width:5%">{{l('RecordId')}}</th>
                                                    <th>{{l('ID')}}</th>
                                                    <th>{{l('value')}}</th>
                                                </tr>
                                            </ng-template>
                                            <ng-template pTemplate="body" let-record let-i="rowIndex">
                                                <tr>
                                                    <td class="ui-resizable-column">
                                                        <div class="btn-group dropdown" normalizePosition>
                                                            <button class="dropdown-toggle btn btn-sm btn-primary"
                                                                data-toggle="dropdown" aria-haspopup="true"
                                                                aria-expanded="false">
                                                                <i class="fa fa-cog"></i>
                                                                <span class="caret"></span> {{l("Actions")}}
                                                            </button>
                                                            <ul class="dropdown-menu">
                                                                <li>
                                                                    <a class="icon-bianji dropdown-item"
                                                                        (click)="editPropertyValue(record)">{{l('Edit')}}</a>
                                                                </li>
                                                                <li>
                                                                    <a class="icon-icon-test dropdown-item"
                                                                        (click)="deletePropertyValue(record)">{{l('Delete')}}</a>
                                                                </li>
                                                            </ul>
                                                        </div>
                                                    </td>
                                                    <td class="ui-resizable-column"> {{transIndex(i)}}</td>
                                                    <td class="ui-resizable-column">{{record.id}}</td>
                                                    <td class="ui-resizable-column">{{record.value}}</td>
                                                </tr>
                                            </ng-template>
                                            <ng-template pTemplate="emptymessage" let-records>
                                                <tr *ngIf="primengTableHelper.records">
                                                    <td colspan="4">

                                                    </td>
                                                </tr>
                                            </ng-template>
                                        </p-table>
                                        <div class="primeng-paging-container">
                                            <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage"
                                                #paginator (onPageChange)="getPropertyValue($event)"
                                                [totalRecords]="primengTableHelper.totalRecordsCount"
                                                [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                                            </p-paginator>
                                            <span class="total-records-count">
                                                {{l('TotalRecordsCount', primengTableHelper.totalRecordsCount)}}
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </tab>
                        </tabset>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <PropertyValueAlertModal #PropertyValueAlertModal (modalSave)="getPropertyValue($event)"></PropertyValueAlertModal>